<?php


namespace app\repository;


use app\model\DeviceCard;

class LogsRepository extends Repository
{
    public function list($data)
    {
        $builder = DeviceCard::query()->orderByDesc("created_at");
        if ($data["type"]){
            $builder = $builder->where("channel", $data["type"]);
        }
        $count = $builder->count();
        $collection = $builder->limit($data["page_size"])->offset($data["page_size"] * ($data["page_no"] - 1))->get();
        return $this->success([
            "list"=>$collection,
            "count"=>$count,
            "page_size"=>$data["page_size"],
            "page_no"=>$data["page_no"]
        ]);
    }

}